#ifndef  _SERVER_RECV_H_
#define  _SERVER_RECV_H_

#include "../define/define.h"
#include "./buffer.h"
#include "../util/netstm.h"
#include "../util/lock.h"

class server_recv 
{
public:
	
    server_recv()
	{
		func_lock locker;
		m_log = new logfile("server_recv");

		m_buffer.create(0,0);
	}

	~server_recv()
	{
		delete m_log;
		func_lock locker;
	}

	bool init(uint32 socket)
	{
		m_buffer.set_socket(socket);
		return true;
	}

	bool free()
	{
		m_buffer.reset();
		return true;
	}

	uint32 put_data(char* buf, uint32 buf_size,uint32 data_id)
	{
		func_lock locker;
		return m_buffer.add_packet(data_id,buf,buf_size);
	}

	uint32  set_max_id(uint32 last_id)
	{
		return m_buffer.set_last_id(last_id);
	}
	
	uint32  get_data(char* buf, uint32* buf_size,uint32* data_id)
	{
		func_lock locker;
		return m_buffer.read_data(buf,buf_size,data_id);
	}

	uint32 set_size(uint32 data_id, uint32 size)
	{
        func_lock locker;
		return m_buffer.set_size(data_id,size);
	}

private:
	
	buffer      m_buffer;
	logfile*    m_log;
};


#endif